import 'package:flutter/material.dart';

/**
 * 组件化开发（自定义的widget）
 */
class MyDialog extends StatefulWidget {
  final String content1;

  const MyDialog({super.key, required this.content1});

  @override
  State<MyDialog> createState() => _MyDialogState();
}

class _MyDialogState extends State<MyDialog> {
  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      title: Text('标题'),

      ///引用属性
      content: Text(widget.content1),
      actions: [
        TextButton(
            onPressed: () {
              Navigator.pop(context);
            },
            child: Text('确认')),
        TextButton(
            onPressed: () {
              Navigator.pop(context);
            },
            child: Text('取消'))
      ],
    );
  }
}
